﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class user_Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
    }

    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {

    }

    protected void zhuce_Click(object sender, EventArgs e)
    {
        string username = this.yhm.Text;
        string password = this.mm.Text;
        string qrpassword = this.qrmm.Text;
        string phone = this.sjh.Text;
        if (password == qrpassword)
        {
            //客户注册添加数据sql语句
            string sql = "insert into [客户](客户名,密码,手机号) values('" + username + "','" + password + "','" + phone + "')";
            if (Insert(sql) == 1)
            {
                this.Label1.Visible = true;
                this.Label1.Text = "注册成功！";
                Response.Redirect("Login.aspx");
            }
            else
            {
                this.yhm.Text = "";
                this.mm.Text = "";
                this.qrmm.Text = "";
                this.sjh.Text = "";
                this.Label1.Visible = true;
                this.Label1.Text = "注册失败！";
            }
            
        }
    }
    public static int Insert(string sql)
    {
        String strConnection = "server=.;database=keshe2;Integrated Security=SSPI";
        SqlConnection conn = new SqlConnection(strConnection);
        conn.Open();
        SqlCommand cmd = new SqlCommand(sql, conn);
        int a;
        try
        {
            a = cmd.ExecuteNonQuery();
        }
        catch
        {
            a = 0;
        }
        conn.Close();
        return a;
    }

}